home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / gas / gassrc04.zoo / as.h < prev    next >
C/C++ Source or Header  |  1991-07-28  |  9KB  |  297 lines

  1. /* as.h - global header file
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef asH
  21. #define asH            /* Don't declare things twice. */
  22.  
  23. #if !defined(__STDC__) && !defined(const)
  24. #define const /* ignore */
  25. #endif
  26.  
  27. #ifdef USG
  28. #define index strchr
  29. #define bzero(s,n) memset((s),0,(n))
  30. #define bcopy(from,to,n) memcpy((to),(from),(n))
  31. #define setbuffer(a,b,c)
  32. #endif
  33.  
  34. #ifdef CROSSHPUX
  35. #define setbuffer(a,b,c)
  36. #endif
  37.  
  38. /*
  39.  * CAPITALISED names are #defined.
  40.  * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
  41.  * "lowercaseT" is a typedef of "lowercase" objects.
  42.  * "lowercaseP" is type "pointer to object of type 'lowercase'".
  43.  * "lowercaseS" is typedef struct ... lowercaseS.
  44.  *
  45.  * #define SUSPECT when debugging.
  46.  * #define DUMP to include data-structure dumpers.
  47.  * #define COMMON as "extern" for all modules except one, where you #define
  48.  *    COMMON as "".
  49.  * If TEST is #defined, then we are testing a module: #define COMMON as "".
  50.  */
  51.  
  52.  
  53.  
  54. /* These #defines are for parameters of entire assembler. */
  55.  
  56. /* #define SUSPECT JF remove for speed testing */
  57. /* #define DUMP */
  58. #define NDEBUG        /* JF disable asserts */
  59. /* These #includes are for type definitions etc. */
  60.  
  61. /* #include "style.h" */
  62. #include <stdio.h>
  63. #include <assert.h>
  64. #define obstack_chunk_alloc    xmalloc
  65. #define obstack_chunk_free    xfree
  66.  
  67. /* These defines are potentially useful */
  68. #define FALSE    (0)
  69. #define TRUE    (!FALSE)
  70. #define ASSERT    assert
  71. #define BAD_CASE(value)                            \
  72. {                                    \
  73.   as_fatal ("Case value %d unexpected at line %d of file \"%s\"\n",    \
  74.        value, __LINE__, __FILE__);                    \
  75. }
  76.  
  77.  
  78.  
  79.  
  80. /* These are assembler-wide concepts */
  81.  
  82.  
  83. #ifndef COMMON
  84. #ifdef TEST
  85. #define COMMON            /* declare our COMMONs storage here. */
  86. #else
  87. #define COMMON extern        /* our commons live elswhere */
  88. #endif
  89. #endif
  90.                 /* COMMON now defined */
  91.  
  92. #ifdef SUSPECT
  93. #define register        /* no registers: helps debugging */
  94. #define know(p) ASSERT(p)    /* know() is less ugly than #ifdef SUSPECT/ */
  95.                 /* assert()/#endif. */
  96. #else
  97. #define know(p)            /* know() checks are no-op.ed */
  98. #endif                /* #ifdef SUSPECT */
  99.  
  100.  
  101. char    *xmalloc();        /* keep C compilers happy */
  102. char    *xrealloc();        /* " */
  103. void    free();            /* " */
  104. #define xfree free
  105.  
  106. /* input_scrub.c */
  107.  
  108. /*
  109.  * Supplies sanitised buffers to read.c.
  110.  * Also understands printing line-number part of error messages.
  111.  */
  112.  
  113.                 /* Line number things. */
  114. int    seen_at_least_1_file();
  115. void    bump_line_counters();
  116. void    new_logical_line();
  117. void    as_where();
  118. void    as_perror();
  119. void    as_howmuch();
  120.                 /* Sanitising things. */
  121. void    input_scrub_begin();
  122. void    input_scrub_end();
  123. char    *input_scrub_new_file();
  124. char    *input_scrub_next_buffer();
  125.  
  126. /* subsegs.c     Sub-segments. Also, segment(=expression type)s.*/
  127.  
  128. /*
  129.  * This table describes the use of segments as EXPRESSION types.
  130.  *
  131.  *    X_seg    X_add_symbol  X_subtract_symbol    X_add_number
  132.  * SEG_NONE                        no (legal) expression
  133.  * SEG_PASS1                        no (defined) "
  134.  * SEG_BIG                    *    > 32 bits const.
  135.  * SEG_ABSOLUTE                         0
  136.  * SEG_DATA        *                 0
  137.  * SEG_TEXT        *            0
  138.  * SEG_BSS        *            0
  139.  * SEG_UNKNOWN        *            0
  140.  * SEG_DIFFERENCE    0        *    0
  141.  *
  142.  * The blank fields MUST be 0, and are nugatory.
  143.  * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
  144.  *
  145.  * SEG_BIG: X_add_number is < 0 if the result is in
  146.  *    generic_floating_point_number.  The value is -'c' where c is the
  147.  *    character that introduced the constant.  e.g. "0f6.9" will have  -'f'
  148.  *    as a X_add_number value.
  149.  *    X_add_number > 0 is a count of how many littlenums it took to
  150.  *    represent a bignum.
  151.  * SEG_DIFFERENCE:
  152.  * If segments of both symbols are known, they are the same segment.
  153.  * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
  154.  */
  155.  
  156. typedef enum
  157. {
  158.     SEG_ABSOLUTE,
  159.     SEG_TEXT,
  160.     SEG_DATA,
  161.     SEG_BSS,
  162.     SEG_UNKNOWN,
  163.     SEG_NONE,        /* Mythical Segment: NO expression seen. */
  164.     SEG_PASS1,        /* Mythical Segment: Need another pass. */
  165.     SEG_GOOF,        /* Only happens if AS has a logic error. */
  166.                 /* Invented so we don't crash printing */
  167.                 /* error message involving weird segment. */
  168.     SEG_BIG,            /* Bigger than 32 bits constant. */
  169.     SEG_DIFFERENCE        /* Mythical Segment: absolute difference. */
  170. }        segT;
  171. #define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
  172.  
  173. typedef unsigned char    subsegT;
  174.  
  175. COMMON subsegT            now_subseg;
  176.                 /* What subseg we are accreting now? */
  177.  
  178.  
  179. COMMON segT            now_seg;
  180.                 /* Segment our instructions emit to. */
  181.                 /* Only OK values are SEG_TEXT or SEG_DATA. */
  182.  
  183.  
  184. extern char *const seg_name[];
  185. extern const int   seg_N_TYPE[];
  186. extern const segT  N_TYPE_seg[];
  187. void    subsegs_begin();
  188. void    subseg_change();
  189. void    subseg_new();
  190.  
  191. /* relax() */
  192.  
  193. typedef enum
  194. {
  195.     rs_fill,        /* Variable chars to be repeated fr_offset */
  196.                 /* times. Fr_symbol unused. */
  197.                 /* Used with fr_offset == 0 for a constant */
  198.                 /* length frag. */
  199.  
  200.     rs_align,        /* Align: Fr_offset: power of 2. */
  201.                 /* 1 variable char: fill character. */
  202.     rs_org,            /* Org: Fr_offset, fr_symbol: address. */
  203.                 /* 1 variable char: fill character. */
  204.  
  205.     rs_machine_dependent,
  206. #ifndef WORKING_DOT_WORD
  207.     rs_broken_word,        /* JF: gunpoint */
  208. #endif
  209. }
  210. relax_stateT;
  211.  
  212. /* typedef unsigned char relax_substateT; */
  213. /* JF this is more likely to leave the end of a struct frag on an align
  214.    boundry.  Be very careful with this.  */
  215. typedef unsigned long int relax_substateT;
  216.  
  217. typedef unsigned long int relax_addressT;/* Enough bits for address. */
  218.                 /* Still an integer type. */
  219.  
  220.  
  221. /* frags.c */
  222.  
  223. /*
  224.  * A code fragment (frag) is some known number of chars, followed by some
  225.  * unknown number of chars. Typically the unknown number of chars is an
  226.  * instruction address whose size is yet unknown. We always know the greatest
  227.  * possible size the unknown number of chars may become, and reserve that
  228.  * much room at the end of the frag.
  229.  * Once created, frags do not change address during assembly.
  230.  * We chain the frags in (a) forward-linked list(s). The object-file address
  231.  * of the 1st char of a frag is generally not known until after relax().
  232.  * Many things at assembly time describe an address by {object-file-address
  233.  * of a particular frag}+offset.
  234.  
  235.  BUG: it may be smarter to have a single pointer off to various different
  236. notes for different frag kinds. See how code pans out.
  237.  
  238.  
  239.  */
  240. struct frag            /* a code fragment */
  241. {
  242.     long unsigned int fr_address; /* Object file address. */
  243.     struct frag *fr_next;    /* Chain forward; ascending address order. */
  244.                 /* Rooted in frch_root. */
  245.  
  246.     long int fr_fix;    /* (Fixed) number of chars we know we have. */
  247.                 /* May be 0. */
  248.     long int fr_var;    /* (Variable) number of chars after above. */
  249.                 /* May be 0. */
  250.     struct symbol *fr_symbol; /* For variable-length tail. */
  251.     long int fr_offset;    /* For variable-length tail. */
  252.     char    *fr_opcode;    /*->opcode low addr byte,for relax()ation*/
  253.     relax_stateT fr_type;   /* What state is my tail in? */
  254.     relax_substateT    fr_subtype;
  255.         /* These are needed only on the NS32K machines */
  256.     char    fr_pcrel_adjust;
  257.     char    fr_bsr;
  258.     char    fr_literal [1];    /* Chars begin here. */
  259.                 /* One day we will compile fr_literal[0]. */
  260. };
  261. #define SIZEOF_STRUCT_FRAG \
  262.  ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
  263.                 /* We want to say fr_literal[0] above. */
  264.  
  265. typedef struct frag fragS;
  266.  
  267. COMMON fragS *    frag_now;    /* -> current frag we are building. */
  268.                 /* This frag is incomplete. */
  269.                 /* It is, however, included in frchain_now. */
  270.                 /* Frag_now->fr_fix is bogus. Use: */
  271. /* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/
  272.  
  273. COMMON fragS zero_address_frag;    /* For foreign-segment symbol fixups. */
  274. COMMON fragS  bs